<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <title>用户登录</title>
    <link href="../ladmin/favicon.ico" rel="shortcut icon" type="image/x-icon">
    <link href="../ladmin/css/login.css" rel="stylesheet" type="text/css">
    <link href="../ladmin/css/xadmin.css" rel="stylesheet" type="text/css">
    <link href="../ladmin/css/font.css" rel="stylesheet" type="text/css">
    <link href="../ladmin/lib/layui/css/modules/layer/default/layer.css" rel="stylesheet" type="text/css">
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
    <script charset="utf-8" src="../ladmin/lib/layui/layui.js"></script>
    <script src="../ladmin/js/xadmin.js" type="text/javascript"></script>
</head>
<body>
<div class="login-page" id="wrapper">
    <div class="form" id="login_form">
        <form class="login-form">

            <input id="studentID" maxlength="12" name="studentID"
                   onkeyup="value=value.replace(/[^1234567890-]+/g,'')" placeholder="学号"
                   type="text"/>

            <input id="password" name="password"
                   placeholder="密码"
                   type="password"/>
            <button id="login">登　录</button>
        </form>
    </div>

</div>
<script type="text/javascript">

    function check_login() {

        $.ajax({

            type: 'POST',
            url: 'login',
            async: true,
            data: JSON.stringify({
                id: $("#studentID").val(),
                passwordMD5: $("#password").val()
            }),
            dataType: 'Text',
            contentType: "application/Json;charset=UTF-8",
            success: function (data) {
                if (data == "true") {
                    layer.msg('登录成功');
                    setTimeout(function () {
                        document.location = "index";
                    }, 2000);


                } else {
                    layer.msg('验证失败');
                    $("#login_form").removeClass('shake_effect');
                    setTimeout(function () {
                        $("#login_form").addClass('shake_effect')
                    }, 1);
                }


            }

        });
    }


    $(function () {

        $("#login").click(function () {
            check_login();
            return false;
        })
    })

</script>
</body>
</html>